MySQL Server 安裝


Posted by kscheng on 2021-04-06

#!/bin/bash

###########################################################
# Program: MySQL installation via Ubuntu 20.04
# DBAdmin: K.C. Cheng
# Created: March 31st, 2021
# Source :
###########################################################

echo ''
echo '[check ubuntu version]'
lsb_release -a
    # the simple description
    # $ lsb_release -d

echo ''
echo '[start MySQL installation]'
sudo apt update
yes y | sudo apt install mysql-server
#
# Configuration file '/etc/apparmor.d/usr.sbin.mysqld'
#  ==> File on system created by you or by a script.
#  ==> File also in package provided by package maintainer.
#    What would you like to do about it ?  Your options are:
#     Y or I  : install the package maintainer's version
#     N or O  : keep your currently-installed version
#       D     : show the differences between the versions
#       Z     : start a shell to examine the situation
#  The default action is to keep your current version.
# *** usr.sbin.mysqld (Y/I/N/O/D/Z) [default=N] ?
Y

echo ''
echo '[check the server status after installation]'
    # $ sudo systemctl status mysql

echo ''
echo '[perform several security-related operation]'
sudo mysql_secure_installation
#
# Securing the MySQL server deployment.
#
# Connecting to MySQL using a blank password.
#
# VALIDATE PASSWORD COMPONENT can be used to test passwords
# and improve security. It checks the strength of password
# and allows the users to set only those passwords which are
# secure enough. Would you like to setup VALIDATE PASSWORD
# component?
#
# Press y|Y for Yes, any other key for No:
Y

#
# There are three levels of password validation policy:
#
# LOW    Length >= 8
# MEDIUM Length >= 8, numeric, mixed case, and special
# characters
# STRONG Length >= 8, numeric, mixed case, special
# characters and directorary file
#
# Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:
2


# Please set the password for root here.
#
# New password:
!QAZ2wsx
# Re-enter new password:
!QAZ2wsx


# Estimated strength of the password: 100
# Do you wish to continue with the password provided?(Press
# y|Y for Yes, any other key for No) :
Y


# By default, a MySQL installation has an anonymous user,
# allowing anyone to log into MySQL without having to have
# a user account created for them. This is intended only for
# testing, and to make the installation go a bit smoother.
# You should remove them before moving into a production
# environment.
#
# Remove anonymous users? (Press y|Y for Yes, any other key
# for No) :
Y
# Success.


#
# Normally, root should only be allowed to connect from
# 'localhost'. This ensures that someone cannot guess at
# the root password from the network.
#
# Disallow root login remotely? (Press y|Y for Yes, any other
# key for No) :
Y
# Success.


# By default, MySQL comes with a database named 'test' that
# anyone can access. This is also intended only for testing,
# and should be removed before moving into a production
# environment.
#
#
# Remove test database and access to it? (Press y|Y for Yes,
# any other key for No) :
Y
#  - Dropping test database...
# Success.
#
# - Removing privileges on test database...
# Success.

# Reloading the privilege tables will ensure that all changes
# made so far will take effect immediately.
#
# Reload privilege tables now? (Press y|Y for Yes, any other
# key for No) :
Y
# Success.

# All done!


echo ''
echo '[test mysql server]'
sudo mysql -e 'select now();'

#MySQL #installation







Related Posts

How to Set Up Firewall with UFW on Ubuntu 20.04

How to Set Up Firewall with UFW on Ubuntu 20.04

git 狀況劇

git 狀況劇

ASP.NET Core Web API 入門教學 - 範例檔使用LocalDB練習

ASP.NET Core Web API 入門教學 - 範例檔使用LocalDB練習


Comments